package com.chris.blog.service.impl;

import com.chris.blog.dao.QuestionDao;
import com.chris.blog.entity.po.QuestionPO;
import com.chris.blog.service.QuestionService;
import com.github.pagehelper.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class QuestionServiceImpl implements QuestionService {

    @Resource
    private QuestionDao questionDAO;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return questionDAO.deleteByPrimaryKey(id);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int insert(QuestionPO record) {
        return questionDAO.insert(record);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int insertSelective(QuestionPO record) {
        return questionDAO.insertSelective(record);
    }

    @Override
    public QuestionPO selectByPrimaryKey(Integer id) {
        return questionDAO.selectByPrimaryKey(id);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int updateByPrimaryKeySelective(QuestionPO record) {
        return questionDAO.updateByPrimaryKeySelective(record);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int updateByPrimaryKey(QuestionPO record) {
        return questionDAO.updateByPrimaryKey(record);
    }

    public Page<QuestionPO> findAllDesc() {
        return questionDAO.findAllDesc();
    }

    public Page<QuestionPO> findAllByCIdDesc(Integer cid) {
        return questionDAO.findAllByCIdDesc(cid);
    }

    public QuestionPO findOneByQid(Long qid) {
        return questionDAO.findOneByQid(qid);
    }

    public int count(String uid) {
        return questionDAO.count(uid);
    }

    public Page<QuestionPO> findAllByUidDesc(String uid) {
        return questionDAO.findAllByUidDesc(uid);
    }
}
